home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 574 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.7 KB  |  132 lines

  1. Path: su3.in.net!news
  2. From: mave@in.net (John J. Maver)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Help me with a basic MUI program PLEASE?
  5. Date: 9 Jan 1996 11:35:32 GMT
  6. Organization: INTERNET Indiana
  7. Message-ID: <2440.6581T1279T1051@in.net>
  8. Reply-To: mave@in.net
  9. NNTP-Posting-Host: pm4-18.in.net
  10. X-Newsreader: THOR 2.22 (Amiga;TCP/IP)
  11.  
  12.  
  13.  
  14.     Could someone please help me with MUI?  I have started trying to use
  15. MUIBuilder,and I can't seem to make a good main.c to control the code it
  16. generates.  I am new to MUI.  All I want to know is how to open the window and
  17. then when the person hits the close gadget, have the window close.  With my
  18. existing main.c. the window opens and is open for good!!
  19.  
  20.     Is there a good reference for MUI?  Some basic examples, not some 18 part
  21. multiprogram.
  22.  
  23.     Thank you for your help.
  24.  
  25.     Test.h and Test.c follow
  26.  
  27.  
  28. <tsb>
  29.  
  30. /*******************/
  31. /* this is test.h  */
  32. /*******************/
  33.  
  34. #include <libraries/mui.h>
  35. #include <proto/muimaster.h>
  36. #include <clib/exec_protos.h>
  37. #include <exec/memory.h>
  38. #include <clib/alib_protos.h>
  39.  
  40. struct ObjApp
  41. {
  42.     APTR    App;
  43.     APTR    WI_label_0;
  44. };
  45.  
  46.  
  47. extern struct ObjApp * CreateApp(void);
  48. extern void DisposeApp(struct ObjApp *);
  49.  
  50.  
  51. <sb>
  52.  
  53. /****************/
  54. /*This is test.c*/
  55. /****************/
  56.  
  57.  
  58. #ifndef MAKE_ID
  59. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 |
  60. (ULONG) (d))
  61. #endif
  62.  
  63. #ifdef _DCC
  64. #define __inline
  65. #endif
  66.  
  67. #include "Test.h"
  68.  
  69. struct ObjApp * CreateApp(void)
  70. {
  71.     struct ObjApp * Object;
  72.  
  73.     APTR    MainWin, TheLabel;
  74.  
  75.     if (!(Object = AllocVec(sizeof(struct ObjApp), MEMF_PUBLIC|MEMF_CLEAR)))
  76.         return(NULL);
  77.  
  78.     TheLabel = Label("LableTitle");
  79.  
  80.     MainWin = GroupObject,
  81.         Child, TheLabel,
  82.     End;
  83.  
  84.     Object->WI_label_0 = WindowObject,
  85.         MUIA_Window_Title, "window_title",
  86.         MUIA_Window_ID, MAKE_ID('0', 'W', 'I', 'N'),
  87.         WindowContents, MainWin,
  88.     End;
  89.  
  90.     Object->App = ApplicationObject,
  91.         MUIA_Application_Author, "Me",
  92.         MUIA_Application_Base, "Test",
  93.         MUIA_Application_Title, "Test",
  94.         MUIA_Application_Version, "$VER: NONE XX.XX (XX.XX.XX)",
  95.         MUIA_Application_Copyright, "NOBODY",
  96.         MUIA_Application_Description, "Test",
  97.         SubWindow, Object->WI_label_0,
  98.     End;
  99.  
  100.  
  101.     if (!Object->App)
  102.     {
  103.         FreeVec(Object);
  104.         return(NULL);
  105.     }
  106.  
  107.     DoMethod(Object->WI_label_0,
  108.         MUIM_Window_SetCycleChain, 0
  109.         );
  110.  
  111.     set(Object->WI_label_0,
  112.         MUIA_Window_Open, TRUE
  113.         );
  114.  
  115.  
  116.     return(Object);
  117. }
  118.  
  119. void DisposeApp(struct ObjApp * Object)
  120. {
  121.     MUI_DisposeObject(Object->App);
  122.     FreeVec(Object);
  123. }
  124.  
  125.  
  126.  
  127. --
  128. <tsb> John J. Maver
  129. <sb> A4000/040
  130. You are faithful to duty, adaptable to environment, loyal to friends.
  131.  
  132.